#include "sdl_prim.h"

long sdl_prim::__add_ref()
{
#ifdef __sdl_debug
    if (__debug_level > 2 && __internal_debug_level > 2)
        std::cout << "__internal_debug: " << name() << " ref " << __ref << "->" << __ref + 1 << std::endl;
#endif
    return (++__ref);
}

long sdl_prim::__dec_ref()
{
#ifdef __sdl_debug
    if (__debug_level > 2 && __internal_debug_level > 2)
        std::cout << "__internal_debug: " << name() << " ref " << __ref << "->" << __ref - 1 << std::endl;
#endif
    return (--__ref);

}

sdl_prim::sdl_prim(const std::string & n) : __name(n), __ref(0), __internal_debug_level(10)
{
#ifdef __sdl_debug
    if (__debug_level > 1 && __internal_debug_level > 1)
        std::cout << "__internal_debug: " << name() << ": Hello!" << std::endl;
#endif
}

sdl_prim::~sdl_prim()
{
#ifdef __sdl_debug
    if (__debug_level > 1 && __internal_debug_level > 1)
        std::cout << "__internal_debug: " << name() << ": I die..." << std::endl;
#endif
}

const std::string & sdl_prim::name() const
{
    return __name;
}

///definiuję tak, żeby zapobiec przypisaniom do sdl_ptr

sdl_prim * sdl_prim::operator&()
{
    throw sdlex::exception("no C-style pointers to sdl_prim objects allowed");
}

int sdl_prim::__debug_level = 0;
